<?php


namespace App\Http\Requests\Warehousing\Index;


use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateRequest extends FormRequest
{
    /**
     * @return array
     * @author luffyzhao@vip.126.com
     */
    public function rules()
    {
        return [
            'products' => ['required', 'array'],
            'products.*.barcode' => ['required', 'string'],
            'products.*.code' => ['required', Rule::exists('products', 'code')
                ->where('customer_id', $this->input('customer_id'))],
            'products.*.price' => ['required', 'numeric'],
            'products.*.quantity' => ['required', 'integer', 'min:1'],
            'district'=> ['required', 'size:4'],
            'type'=> ['required', 'size:1', 'in:0,1,2'],
            'transport'=> ['required', 'size:1'],
            'packing_code'=> ['required', 'size:1'],
            'weight'=> ['required', 'numeric'],
            'piece'=> ['required', 'numeric'],
            'remark' => ['nullable'],
            'customer_id' => ['required', Rule::exists('customers', 'id')]
        ];
    }
}
